home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
DebugWindow1.4.sit
/
DebugWindow 1.4 ƒ
/
Debug.c
next >
Wrap
Text File
|
1993-09-08
|
2KB
|
107 lines
//============================================================================
//
// This is the Think C 6.0 code to send a message to the DebugWindow server
// (in other words, this is the code to DebugWindow.Lib that came with your
// DebugWindow package). I'm providing this code to document the AppleEvent
// procedures necessary to communicate with DebugWindow; those of you who
// need a specialized version, or need to port it to another environment
// (such as Pascal or MacApp) should find everything that you need to know
// right here.
//
// If you implement this into a new environment, I'd appreciate it if you
// could send me the new modules so that I can include them with the next
// release of DebugWindow (with the proper credits going to you, of course!).
//
//
// Here are the necessary steps to send a string to DebugWindow:
//
// ・ create an AppleEvent for signature 'LdbW' with a type of 'misc/dmsg'
//
// ・ add a parameter of type 'keyDirectObject/typeChar' passing a pointer
// to the string to display and its length
//
// ・ send it on its way
//
//============================================================================
#include <stdio.h>
#include <stdarg.h>
#include <AppleEvents.h>
void __SendToDebugWindow ( char *stringToSend );
void Debug ( char *format, ... )
{
va_list argptr;
long len;
OSErr err;
char tDebugString [512];
va_start ( argptr, format );
len = (long)vsprintf ( tDebugString, format, argptr );
va_end ( argptr );
if ( len > 0 )
__SendToDebugWindow ( tDebugString );
}
void ClearDebugWindow ()
{
__SendToDebugWindow ( "~c" );
}
void DebugTimestamp ()
{
__SendToDebugWindow ( "~t" );
}
void __SendToDebugWindow ( char *stringToSend )
{
AEAddressDesc address;
AppleEvent appleEvent, reply;
OSType targetSig;
targetSig = 'LdbW';
if ( AECreateDesc ( typeApplSignature, (Ptr)&targetSig,
sizeof targetSig, &address ) == 0 ) {
if ( AECreateAppleEvent ( 'misc', 'dmsg', &address, kAutoGenerateReturnID,
kAnyTransactionID, &appleEvent ) == 0 ) {
if ( AEPutParamPtr ( &appleEvent, keyDirectObject, typeChar,
stringToSend, strlen (stringToSend) ) == 0 ) {
AESend ( &appleEvent, &reply,
kAEWaitReply + kAENeverInteract,
kAENormalPriority,
300, // up to 5 second wait..
nil, nil );
AEDisposeDesc ( &reply );
}
AEDisposeDesc ( &appleEvent );
}
AEDisposeDesc ( &address );
}
}